package com.group.itms.routes.data;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

@DatabaseTable()
public class ObjectType {

	public static final String IS_ACTIVE = "isActive";
	
	public static final ObjectType LOCATION = new ObjectType(1, "Location");
	public static final ObjectType ROUTE = new ObjectType(2, "Route");
	public static final ObjectType INF_POINT = new ObjectType(3,
			"Information Point");
	public static final ObjectType TASK = new ObjectType(4, "Task");
	public static final ObjectType INF_DESC = new ObjectType(5,
			"Information Desk");

	@DatabaseField(id = true)
	private int id;
	@DatabaseField
	private String name;
	@DatabaseField(columnName = IS_ACTIVE)
	private boolean isActive;

	public static ObjectType getInstance(int id) {
		switch (id) {
		case 1:
			return LOCATION;
		case 2:
			return ROUTE;
		case 3:
			return INF_POINT;
		case 4:
			return TASK;
		case 5:
			return INF_DESC;
		default:
			return null;
		}
	}

	public ObjectType() {

	}

	public ObjectType(String name) {
		this.name = name;
	}

	public ObjectType(int id, String name) {
		this.id = id;
		this.name = name;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Override
	public String toString() {
		return "ObjectType[name=" + name + "]";
	}

	@Override
	public boolean equals(Object o) {
		if (!(o instanceof ObjectType)) {
			return false;
		}
		ObjectType other = (ObjectType) o;
		return id == (other.id);
	}

	public boolean isActive() {
		return isActive;
	}

	public void setActive(boolean isActive) {
		this.isActive = isActive;
	}

}
